package com.atguigu.guli.service.statistics.task;

import com.atguigu.guli.service.statistics.service.DailyService;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author lj on 2021/2/18.
 * @version 1.0
 */
@Component
@Slf4j
public class ScheduledTask {
    @Autowired
    private DailyService dailyService;
    //在线生成cron表达式
    //http://cron.qqe2.com/
    @Scheduled(cron = "0/3 * * * * *")
    public void task1(){
      log.info("task1执行了。。。");
      //得到前一天的用户数据
        final String yesterday = new DateTime().minusDays(1).toString("yyyy-MM-dd");
        dailyService.createStatisticsByDay(yesterday);
    }

}
